package com.huawei.appmarket.service.appdetail.view.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSViewProxy;
import com.huawei.appgallery.foundation.ui.css.RenderListener;
import com.huawei.appgallery.foundation.ui.css.adapter.CSSPropertyName;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSMonoColor;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSValue;
import huawei.widget.HwButton;
import o.bue.b;
import o.bvj.j;
import o.Logger;
import o.epo;
import o.erq;
import o.ewm.e;

public class DetailFollowSectionButton extends HwButton implements RenderListener {
    private boolean ˊ = false;
    private int ˋ;
    private boolean ॱ = false;

    public DetailFollowSectionButton(Context context) {
        super(context);
    }

    public DetailFollowSectionButton(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public DetailFollowSectionButton(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    public void setImmersion(boolean z) {
        this.ॱ = z;
    }

    public void ॱ(boolean z) {
        this.ˊ = z;
        ˎ();
        if (this.ॱ) {
            ˏ();
        } else {
            ˊ();
        }
    }

    private void ˎ() {
        if (this.ˊ) {
            setText(j.ᐨ);
        } else {
            setText(j.ᶥ);
        }
    }

    private void ˊ() {
        if (this.ˊ) {
            setTextColor(getResources().getColor(b.ˊ));
        } else {
            setTextColor(getResources().getColor(b.ᐝ));
        }
    }

    private void ˏ() {
        try {
            if (this.ˊ) {
                setTextColor(erq.ˊ(this.ˋ, 0.5f));
            } else {
                setTextColor(this.ˋ);
            }
        } catch (Exception e) {
            Logger.e("DetailFollowSectionButton", "refreshImmersionTextColor exception");
        }
    }

    public boolean onRenderReady(CSSViewProxy cSSViewProxy) {
        CSSRule rule = cSSViewProxy.getRule();
        View view = cSSViewProxy.getView();
        if (rule.getStyleDeclaration() != null) {
            CSSValue propertyValue = rule.getStyleDeclaration().getPropertyValue(CSSPropertyName.FONT_COLOR);
            if (propertyValue instanceof CSSMonoColor) {
                CSSMonoColor cSSMonoColor = (CSSMonoColor) propertyValue;
                Drawable drawable = view.getContext().getResources().getDrawable(e.ʽॱ);
                int color = cSSMonoColor.getColor();
                this.ˋ = color;
                ˏ();
                setBackground(epo.ॱ(drawable, color));
            }
        }
        return false;
    }
}
